package com.xyazm.order.remote;

import com.xyazm.common.core.JsonResult;
import com.xyazm.common.utils.CheckResultUtil;
import com.xyazm.fulfill.api.IFulfillApi;
import com.xyazm.fulfill.domain.param.CancelFulfillParam;
import com.xyazm.fulfill.domain.param.TriggerFulFillParam;
import com.xyazm.fulfill.domain.param.TriggerOrderAfterFulfillEventParam;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * 履约服务远程调用接口
 * @author xuyou
 * @date 2022年11月20日 21:51
 */
@Component
public class FulfillRemote {

    @DubboReference(version = "1.0.0")
    private IFulfillApi fulfillApi;

    /**
     * 取消订单履约
     * @author xuyou
     * 2022-11-20 21:53
    */
    public void cancelFulfill(CancelFulfillParam cancelFulfillParam) {
        // 履约通知停止配送
        JsonResult<Void> result = fulfillApi.cancelFulfill(cancelFulfillParam);
        // 检查api调用结果
        CheckResultUtil.checkResult(result,"履约通知停止配送");
    }

    /**
     * 触发订单履约
     * @author xuyou
     * 2023-02-08 22:39
    */
    public void triggerFulFill(TriggerFulFillParam triggerFulFillParam) {
        // 触发订单履约
        JsonResult<Void> result = fulfillApi.triggerFulFill(triggerFulFillParam);
        // 检查api调用结果
        CheckResultUtil.checkResult(result,"触发订单履约");
    }

    /**
     * 触发订单物流配送结果事件接口
     * @author xuyou
     * 2023-02-08 22:39
     */
    public void triggerOrderWmsShipEvent(
            TriggerOrderAfterFulfillEventParam triggerOrderAfterFulfillEventParam) {
        // 触发订单履约
        JsonResult<Void> result = fulfillApi.triggerOrderWmsShipEvent(triggerOrderAfterFulfillEventParam);
        // 检查api调用结果
        CheckResultUtil.checkResult(result,"触发订单物流配送结果事件");
    }

}
